﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace AlbumArtOrganizer.Model
{
    public abstract class Album : IAlbum, INotifyPropertyChanged
    {
        public virtual IArtist Artist
        {
            get;
            set;
        }

        public virtual string Title
        {
            get;
            set;
        }

        public virtual DateTime? ReleaseDate
        {
            get;
            set;
        }

        public string ReleaseDateString
        {
            get
            {
                if (ReleaseDate.HasValue)
                {
                    return ReleaseDate.Value.ToString("yyyy-MM-dd");
                }
                else
                {
                    return "";
                }
            }
        }

        ICoverImage _coverImage = null;
        public virtual ICoverImage CoverImage
        {
            get
            {
                return _coverImage;
            }
            set
            {
                _coverImage = value;
                _coverImage.PropertyChanged += new PropertyChangedEventHandler((sender, e) => OnPropertyChanged("CoverImage"));
            }
        }

        private bool _isExpanded;
        public bool IsExpanded
        {
            get
            {
                return _isExpanded;
            }
            set
            {
                _isExpanded = value;
                this.OnPropertyChanged("IsExpanded");
            }
        }

        private bool _isSelected;
        public bool IsSelected
        {
            get
            {
                return _isSelected;
            }
            set
            {
                _isSelected = value;
                this.OnPropertyChanged("IsSelected");
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        public void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
